package com.sifang.controller;

import com.sifang.domain.Mecha;
import com.sifang.domain.PageBean;
import com.sifang.domain.Result;
import com.sifang.service.IMechaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/mecha")
public class MechaController {

    @Autowired
    private IMechaService iMechaService;

    //机甲详情
    @GetMapping("/detail")
    public Result<Mecha> detail(Integer mechaId){
        Mecha m = iMechaService.detail(mechaId);
        return Result.success(m);
    }

    //机甲分页显示
    @GetMapping
    public Result<PageBean<Mecha>> list(Integer pageNum,Integer pageSize,@RequestParam(required = false) String sortId){
        PageBean<Mecha> pb =  iMechaService.list(pageNum,pageSize,sortId);
        return Result.success(pb);
    }

}
